unit uIsPalindrome;

interface

function IsPalindrome(const aString: string): Boolean;

implementation

uses
  Character,
  SysUtils,
  Spring.Collections,
  Spring.Collections.Extensions;

function IsPalindrome(const aString: string): Boolean;
var
  Stack: IStack<Char>;
  C: Char;
begin
  stack := TCollections.CreateStack<Char>;
  for C in aString do
  begin
    if TCharacter.IsLetter(C) then
      Stack.Push(TCharacter.ToLower(C));
  end;
  Result := Stack.EqualsTo(TReverseIterator<Char>.Create(Stack));
end;

end.
